<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

require dirname(__FILE__).'/pc_controller.php';

require_once dirname(__FILE__).'/menu.php';

class Youku_answer extends PC_controller {

    public function __construct(){
        parent::__construct();
        $this->load->model('Youkuanswermodel','m_answer');
    }

    public function index(){
        $data = parent::index();

        $this->load->view('admin/youku_answer',$data);
    }

    public function getAnswerList() {
        $assist['where'] = getFilter($this->input->post(),Youkuanswermodel::$searchField);
        $assist['like'] = getFilter($this->input->post(),Youkuanswermodel::$likeField);
        $assist['pagination'] = getPagination($this->input->post());

        list($list,$count) = $this->m_answer->getAnswerListSection($assist);

        $this->response->setSuccess();
        $this->response->setItems($list);
        $this->response->setTotalCount($count);
        $this->response->responseExit();
    }

    public function exportAnswerList() {
        @set_time_limit(0);
        @ini_set('memory_limit', '2048M');


        $assist['where'] = getFilter($this->input->get(),Youkuanswermodel::$applySearchField);
        $assist['like'] = getFilter($this->input->get(),Youkuanswermodel::$applyLikeField);

        list($list,$count) = $this->m_answer->getAnswerListSection($assist);

        $this->load->library('excel');
        $this->excel->init('优酷问答答案_'.date('YmdH').'.xls');
        $this->excel->addSheet('优酷问答答案');
        $this->excel->addTitle(array(
            array('content'=>'id'),
            array('content'=>'问题1'),
            array('content'=>'问题2'),
            array('content'=>'问题3'),
            array('content'=>'问题4'),
            array('content'=>'问题5'),
            array('content'=>'问题6'),
            array('content'=>'问题7'),
            array('content'=>'问题8'),
            array('content'=>'问题9'),
            array('content'=>'问题10'),
            array('content'=>'结果'),
            array('content'=>'提交时间'),
        ));

        $sex_array = array(
            1 => '男',
            2 => '女',
        );
        foreach ($list as $key => $value) {
            $gift_info = array();

            $this->excel->addRow(array(
                array('content' => $value['answer_id']),
                array('content' => $value['answer0']),
                array('content' => $value['answer1']),
                array('content' => $value['answer2']),
                array('content' => $value['answer3']),
                array('content' => $value['answer4']),
                array('content' => $value['answer5']),
                array('content' => $value['answer6']),
                array('content' => $value['answer7']),
                array('content' => $value['answer8']),
                array('content' => $value['answer9']),
                array('content' => $value['answer_result']),
                array('content' => $value['answer_time_create']),
            ));
        }

        $this->excel->freezePanes(1,0);
        $this->excel->generate();
    }

}
/* End of file aa_game_history.php */
/* Location: ./application/controllers/aa_game_history.php */
